<template>
	<div>
		<city-header></city-header>
		<city-search :cities="cities"></city-search>
		<city-list :cityData="cityData" :letter="letter"></city-list>
		<city-alphabet :cityData="cityData" @change="alphabetChange"></city-alphabet>
	</div>
</template>

<script type="text/javascript">
	import CityHeader from './components/header'
	import CitySearch from './components/search'
	import CityList from './components/list'
	import CityAlphabet from './components/Alphabet'
	import axios from 'axios'

	export default {
		name: 'City',
		components: {
			CityHeader,
			CitySearch,
			CityList,
			CityAlphabet,
		},
		data: function(){
			return {
				cityData: {},
				cities: null,
				letter: ''
			}
		},
		methods: {
			getHomeInfo: function(){
		  		axios.get('/api/city.json').then(this.getCity);
		  	},
		  	getCity: function(res){
		  		this.cityData = res.data.data;
		  		this.cities = this.cityData.cities;
		  	},
		  	alphabetChange: function(data){
		  		this.letter = data;
		  	}
	  },
	  mounted: function(){
	  	this.getHomeInfo();
	  }
	}
</script>

<style lang="stylus" scoped>
	 
</style>